package com.atguigu.mybatis.dao;

import com.atguigu.bean.Employee;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Map;

/**
 * @author leimingchao
 * @create 2020-10-09 21:32
 */
public interface EmployeeMapper {

    /**
     * 根据id查询员工
     * @param id
     * @return
     */
    public Employee getEmpById(Integer id);

    public void addEmployee(Employee employee);

    public boolean updateEmployee(Employee employee);

    public void deleteEmployeeById(Integer id);

    public Employee getEmployeeByIdAndLastName(@Param("id") Integer id, @Param("lastName") String lastName);

    public Employee getEmployeeByMap(Map<String,Object> map);

    public List<Employee> getEmployeeList();

    public List<Employee> getEmployeesByLastNameLike(String lastName);

    Employee selectEmp(Integer id);

    /**
     * 返回一条记录的map:key就是列名,值就是对应的值
     * @param id
     * @return
     */
    public Map<String,Object> getEmployeeByIdReturnMap(Integer id);

    /**
     * 多条记录封装一个map:Map<Integer,Employee>:键就是这条记录的主键,值是记录封装后的javaBean
     */
    //告诉mybatis封装这个map的时候使用哪个属性作为map的key
    @MapKey("lastName")
    public Map<String,Employee> getEmployeesByLastNameLikeReturnMap(String lastName);



}
